package com.example.computer_exam_training_sys.controller;

import com.example.computer_exam_training_sys.service.ExamAnalysisService;
import com.example.computer_exam_training_sys.vo.ExamPaperAnalysisResult;
import com.example.computer_exam_training_sys.vo.ExamPaperSummary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/exam-analysis")
@CrossOrigin
public class ExamAnalysisController {

    @Autowired
    private ExamAnalysisService examAnalysisService;

    // 获取试卷整体均分和平均答题时长
    //GET http://localhost:8080/exam-analysis/summary/13{paperId}
    @GetMapping("/summary/{paperId}")
    public ExamPaperSummary getPaperSummary(@PathVariable Integer paperId) {
        return examAnalysisService.getPaperSummary(paperId);
    }

    // 获取试卷易错题分析分页列表
    //GET http://localhost:8080/exam-analysis/easy-mistakes?paperId=14&offset=0&size=10

    @GetMapping("/easy-mistakes")
    public List<ExamPaperAnalysisResult> getEasyMistakeQuestions(
            @RequestParam Integer paperId,
            @RequestParam(defaultValue = "0") int offset,
            @RequestParam(defaultValue = "10") int size) {
        return examAnalysisService.getExamPaperAnalysis(paperId, offset, size);
    }

}
